import 'package:qlevar_router/qlevar_router.dart';
import '../../storylines/main_story/splash_story.dart';
import '../../storylines/auth_story/login_story.dart';
import '../../storylines/auth_story/register_story.dart';
import '../../storylines/main_story/main_story.dart';
import '../../storylines/home_story/ai_helper_story.dart';
import '../../storylines/home_story/challenge_list_story.dart';
import '../../storylines/home_story/rank_list_story.dart';
import '../../storylines/home_story/challenge_detail_story.dart';
import '../../storylines/home_story/event_detail_story.dart';
import '../../storylines/community_story/check_in_story.dart';
import '../../storylines/community_story/dynamic_detail_story.dart';
import '../../storylines/community_story/group_chat_story.dart';
import '../../storylines/community_story/member_list_story.dart';
import '../../storylines/community_story/publish_dynamic.dart';
import '../../storylines/community_story/video_player_story.dart';
import '../../storylines/message_story/single_chat_story.dart';
import '../../storylines/message_story/video_call_story.dart';
import '../../storylines/message_story/follow_fan_story.dart';
import '../../storylines/message_story/like_list_story.dart';
import '../../storylines/user_story/other_story.dart';
import '../../storylines/user_story/setup_story.dart';
import '../../storylines/user_story/edit_story.dart';

/// 路由配置
class MagmaRouter {
  /// 启动页面路由
  static const String splashPath = '/';

  /// 登录页面路由
  static const String loginPath = '/login';

  /// 注册页面路由
  static const String registerPath = '/register';

  /// 主页面路由
  static const String mainPath = '/main';

  /// AI助手页面路由
  static const String aiHelperPath = '/ai-helper';

  /// 挑战列表页面路由
  static const String challengeListPath = '/challenge-list';

  /// 排行榜页面路由
  static const String rankListPath = '/rank-list';

  /// 挑战详情页面路由
  static const String challengeDetailPath = '/challenge-detail/:questId';

  /// 活动详情页面路由
  static const String eventDetailPath = '/event-detail/:eventId';

  /// 打卡页面路由
  static const String checkinPath = '/daily-checkin';

  /// 动态详情页面路由
  static const String dynamicDetailPath = '/dynamic-detail/:dynamicId';

  /// 俱乐部群聊页面路由
  static const String groupChatPath = '/group-chat/:clubId';

  /// 成员列表页面路由
  static const String memberListPath = '/member-list/:clubId';

  /// 发布动态页面路由
  static const String publishDynamicPath = '/publish-dynamic';

  /// 视频播放页面路由
  static const String videoPlayerPath = '/video-player/:videoId';

  /// 单聊页面路由
  static const String singleChatPath = '/single-chat/:userId';

  /// 视频通话页面路由
  static const String videoCallPath = '/video-call/:targetUserId';

  /// 关注粉丝页面路由
  static const String followFanPath = '/follow-fan/:pageType';

  /// 点赞列表页面路由
  static const String likeListPath = '/like-list';

  /// 他人页面路由
  static const String otherUserPath = '/other-user/:userId';

  /// 设置页面路由
  static const String configurationPath = '/configuration';

  /// 编辑资料页面路由
  static const String profileEditPath = '/profile-edit';

  /// 路由配置
  static final routes = [
    QRoute(path: splashPath, builder: () => const SplashStory()),
    QRoute(path: loginPath, builder: () => const LoginStory()),
    QRoute(path: registerPath, builder: () => const RegisterStory()),
    QRoute(path: mainPath, builder: () => const MainNavigator()),
    QRoute(path: aiHelperPath, builder: () => const AiHelperStory()),
    QRoute(path: challengeListPath, builder: () => const ChallengeListStory()),
    QRoute(path: rankListPath, builder: () => const RankListStory()),
    QRoute(
      path: eventDetailPath,
      builder:
          () =>
              EventDetailStory(eventId: QR.params['eventId']?.toString() ?? ''),
    ),
    QRoute(
      path: challengeDetailPath,
      builder:
          () =>
              QuestDetailStory(questId: QR.params['questId']?.toString() ?? ''),
    ),
    QRoute(path: checkinPath, builder: () => const CheckInStory()),
    QRoute(
      path: dynamicDetailPath,
      builder:
          () => DynamicDetailStory(
            dynamicId: QR.params['dynamicId']?.toString() ?? '',
          ),
    ),
    QRoute(
      path: groupChatPath,
      builder:
          () => GroupChatStory(clubId: QR.params['clubId']?.toString() ?? ''),
    ),
    QRoute(
      path: memberListPath,
      builder:
          () => MemberListStory(clubId: QR.params['clubId']?.toString() ?? ''),
    ),
    QRoute(path: publishDynamicPath, builder: () => const PublishDynamic()),
    QRoute(
      path: videoPlayerPath,
      builder:
          () =>
              VideoPlayerStory(videoId: QR.params['videoId']?.toString() ?? ''),
    ),
    QRoute(
      path: singleChatPath,
      builder:
          () => SingleChatStory(userId: QR.params['userId']?.toString() ?? ''),
    ),
    QRoute(
      path: videoCallPath,
      builder:
          () => VideoCallStory(
            targetUserId: QR.params['targetUserId']?.toString() ?? '',
          ),
    ),
    QRoute(
      path: followFanPath,
      builder:
          () => FollowFanStory(
            pageType: QR.params['pageType']?.toString() ?? 'following',
          ),
    ),
    QRoute(path: likeListPath, builder: () => const LikeListStory()),
    QRoute(
      path: otherUserPath,
      builder:
          () => OtherUserStory(userId: QR.params['userId']?.toString() ?? ''),
    ),
    QRoute(path: configurationPath, builder: () => const SetupStory()),
    QRoute(path: profileEditPath, builder: () => const EditStory()),
  ];

  /// 初始化路由
  static void init() {
    QR.setUrlStrategy();
  }
}
